package com.seata.account.feign.impl;

import com.seata.account.feign.AccountFeignClient;
import com.seata.account.service.AccountService;
import com.seata.config.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @Description: ${description}
 * @Author: sobey
 * @Email: sobey178@163.com
 * @Date: 2021/11/20 17:43
 */
@RestController
public class AccountFeignClientImpl implements AccountFeignClient {

    @Autowired
    private AccountService accountService;

    @Override
    @RequestMapping(MAPPING_ACCOUNT_DECREASE)
    public CommonResult decrease(
            @RequestParam("userId") Long userId
            , @RequestParam("money") BigDecimal money
            , @RequestParam(value = "commit") Boolean commit
    ) {
        accountService.decrease(userId,money,commit);
        return new CommonResult("扣减账户余额成功！", 200);
    }
}
